//
//  MoodMessageCell.m
//  ShreddedBread
//
//  Created by BoonZ on 16/8/19.
//  Copyright © 2016年 云之君兮鹏. All rights reserved.
//

#import "MoodMessageCell.h"
#import "dayModel.h"

#import "GetHeightTool.h"


@implementation MoodMessageCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.tagImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.tagImageView.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:self.tagImageView];
        
        self.tagLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        self.tagLabel.backgroundColor = [UIColor orangeColor];
        [self.contentView addSubview:self.tagLabel];
        
        self.descriptionLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        self.descriptionLabel.backgroundColor = [UIColor yellowColor];
        self.descriptionLabel.numberOfLines = 0;
        [self.contentView addSubview:self.descriptionLabel];
        
    }
    
    return self;
}

- (void)setValueWithModel:(dayModel *)model{
    
    self.tagImageView.frame = CGRectMake(15, 10, 30, 30);
    self.tagImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%ld", model.moodDay]];

    
    self.tagLabel.frame = CGRectMake(CGRectGetMaxX(self.tagImageView.frame)+10, self.tagImageView.frame.origin.y, jjScreenWidth - 100, 30);
    self.tagLabel.font = [UIFont systemFontOfSize:14];
    self.tagLabel.text = [NSString getTagStringTag:model.tagDay];
    
    
    self.descriptionLabel.text = [NSString stringWithFormat:@"%@\n%@",[NSString getDateStringFromDate:model.dateDay],model.content];
    self.descriptionLabel.font = [UIFont systemFontOfSize:14];
    
    CGFloat labelHeight = [GetHeightTool getHeightForText:self.descriptionLabel.text font:[UIFont systemFontOfSize:14] width:jjScreenWidth - 100];
   
    NSLog(@"*********---->高度%f",labelHeight);
    
    self.descriptionLabel.frame = CGRectMake(CGRectGetMinX(self.tagLabel.frame), CGRectGetMaxY(self.tagLabel.frame)+ 5, jjScreenWidth - 100, labelHeight);
        
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
